import Vue from 'vue'
import App from './App.vue'
import ElementUI from 'element-ui'
import VueRouter from 'vue-router'
import routes from './routers'
import fHeader from './components/f-header'
import fFooter from './components/f-footer'
import i18n from './i18n/i18n'
import axios from 'axios'
import VueCropper from 'vue-cropper'
import layer from 'vue-layer'
import util from '@/libs/util'

import hljs from 'highlight.js' //导入代码高亮文件
import 'highlight.js/styles/atom-one-dark.css' //导入代码高亮样式
import 'element-ui/lib/theme-chalk/index.css'
import 'element-ui/lib/theme-chalk/display.css'
import './assets/style.css'
import 'vue-awesome/icons'
import 'vue-layer/lib/vue-layer.css'
import Icon from 'vue-awesome/components/Icon'
import md5 from 'js-md5'


Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.use(VueRouter)
Vue.component("f-header", fHeader)
Vue.component("f-footer", fFooter)
Vue.prototype.axios = axios
Vue.use(VueCropper)
Vue.prototype.$layer = layer(Vue);
Vue.prototype.$md5 = md5
Vue.component('icon', Icon);
//自定义一个代码高亮指令
Vue.directive('highlight', function(el) {
    let highlight = el.querySelectorAll('pre code');
    highlight.forEach((block) => {
        hljs.highlightBlock(block)
    })
})


//Vue.use(ElementUI, {
//i18n: (key, value) => i18n.t(key, value)
//})

const router = new VueRouter({
    routes,
    mode: 'history'
})
router.afterEach((to, from, next) => {
    if (to.path != "/home")
        window.scrollTo(0, 0)
});

new Vue({
    router,
    i18n,
    render: h => h(App),
    mounted() {
        util.vm(this) //将当前vm 传递给 util.vm 让其中的提示插件生效
      }
}).$mount('#app')